package com.design.mode.iterator;

/**
 * @author zflu
 * 迭代器设计模式
 * Created by lucky on 2018/9/13.
 */
public class MainIterator {
    public static void main(String[] args) {
        BookShelf bookShelf = new BookShelf(5);
        bookShelf.appendBook(new Book("xx1","张1",10));
        bookShelf.appendBook(new Book("xx2","张2",20));
        bookShelf.appendBook(new Book("xx3","张3",30));
        bookShelf.appendBook(new Book("xx4","张4",40));
        bookShelf.appendBook(new Book("xx5","张5",50));
        Iterator iterator = bookShelf.iterator();
        while (iterator.hashNext()){
            Book next = (Book) iterator.next();
            System.out.println(next.toString());
        }
    }
}
